/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function initPeriodosGrid(){
    $("#periodos_grid").jqGrid({
        url:'getPeriodosList.do',
        editurl:'editPeriodo.do?action=edit',
        datatype: "json",
        width:900,
 colNames:['Periodo','Fecha-Periodo Inicial','Fecha-Periodo final','Fecha de Autorizacion'],
        colModel:[
        {
            name:'periodo',
            index:'periodo',
            sortable: true, 
            editable: true,  
            editrules: { required: true},
            editoptions:{readonly: true},
            //hidden: true , 
            //editable: true, 
            width:55
        }
        ,{
            name:'fechainicial',
            index:'fechainicial',
            sortable: true, 
            editable: true,  
            editrules: { required: true},
            editoptions:{readonly: false},        
            width:55,
             editoptions:{size:12,
				dataInit:function(el){
					$(el).datepicker({dateFormat:'yy-mm-dd'});
				},
				defaultValue: function(){
					var currentTime = new Date();
					var month = parseInt(currentTime.getMonth() + 1);
					month = month <= 9 ? "0"+month : month;
					var day = currentTime.getDate();
					day = day <= 9 ? "0"+day : day;
					var year = currentTime.getFullYear();
					return year+"-"+month + "-"+day;				
				}
			},
			formoptions:{ rowpos:2, elmprefix:"(*)",elmsuffix:"  yyyy-mm-dd" },
			editrules:{required:true}
        }
        ,{
            name:'fechafinal',
            index:'fechafinal',
            sortable: true, 
            editable: true,  
            editrules: { required: true},
            editoptions:{readonly: false},        
            width:55,
            editoptions:{size:12,
				dataInit:function(el){
					$(el).datepicker({dateFormat:'yy-mm-dd'});
				},
				defaultValue: function(){
					var currentTime = new Date();
					var month = parseInt(currentTime.getMonth() + 1);
					month = month <= 9 ? "0"+month : month;
					var day = currentTime.getDate();
					day = day <= 9 ? "0"+day : day;
					var year = currentTime.getFullYear();
					return year+"-"+month + "-"+day;				
				}
			},
			formoptions:{ rowpos:2, elmprefix:"(*)",elmsuffix:"  yyyy-mm-dd" },
			editrules:{required:true}
        },{
            name:'fechaautorizacion',
            index:'fechaautorizacion',
            sortable: true, 
            editable: true,       
            editoptions:{readonly: false},        
            width:55,
            editoptions:{size:12,
				dataInit:function(el){
					$(el).datepicker({dateFormat:'yy-mm-dd'});
				},
				defaultValue: function(){
					var currentTime = new Date();
					var month = parseInt(currentTime.getMonth() + 1);
					month = month <= 9 ? "0"+month : month;
					var day = currentTime.getDate();
					day = day <= 9 ? "0"+day : day;
					var year = currentTime.getFullYear();
					return year+"-"+month + "-"+day;				
				}
			},
			formoptions:{ rowpos:2, elmprefix:"(*)",elmsuffix:"  yyyy-mm-dd" },
			editrules:{required:true}
        }
     ],
        ondblClickRow: function(bancoid){
           // alert(bancoid)    
               
        },
        rowNum:10,
        rowList:[10,20,30],
        pager: '#periodos_pager',
        sortname: 'periodo',
        viewrecords: true,
        sortable: true,
        sortorder: "desc",
        multiselect: true,
        caption:"Mis Autos Asignados",
        loadonce : false,
        rowTotal: 'total',
        records:'records',
        jsonReader: {
            repeatitems: false,
            id: "periodo"
        }
    });
    $("#periodos_grid").jqGrid('navGrid','#periodos_pager',{
        edit:true,
        add:false,
        del:false,
        view :false,
        search: false 
    },{closeAfterEdit:true});

}



